#!/bin/bash

config_path=$DSS_HOME/cfg/dss_vg_conf.ini

echo "cleaning volumn"
while IFS=':' read -r vgname diskname
do
    dd if=/dev/zero of=$diskname bs=2048 count=1000 > /dev/null 2>&1
done < "$config_path"
echo "successfully clean volumn"

echo "creating volumn"
while IFS=':' read -r vgname diskname
do
    dsscmd cv -g $vgname -v $diskname -D $DSS_HOME
done < "$config_path"
echo "successfully create volumn"

echo "deleting PGDATA"
rm -rf $PGDATA
echo "successfully delete PGDATA"

echo "starting dssserver"
dssserver -M -D $DSS_HOME > $DSS_HOME/startdss.log 2>&1 &
echo "successfully start dssserver"
